package com.ecarx.vhaltests.hy11.testcases.time;

import android.car.VehicleAreaType;
import android.hardware.automotive.vehicle.V2_0.VehicleArea;
import android.hardware.automotive.vehicle.V2_0.VehiclePropertyGroup;
import android.hardware.automotive.vehicle.V2_0.VehiclePropertyType;
import android.os.SystemClock;
import android.os.SystemProperties;
import android.util.Log;

import com.ecarx.vhaltests.VhalUnitTestBase;

import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runners.MethodSorters;

import java.util.Calendar;
import java.util.TimeZone;

@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class TimeAndDateTest extends VhalUnitTestBase {
    private static final String TAG = "TimeAndDateTest";
    private static final int TiAndDateIndcnDataValid = 0x80b2 | VehiclePropertyGroup.VENDOR | VehiclePropertyType.INT32 | VehicleArea.GLOBAL;
    private static final int TiAndDateIndcnDay = 0x80b3 | VehiclePropertyGroup.VENDOR | VehiclePropertyType.INT32 | VehicleArea.GLOBAL;
    private static final int TiAndDateIndcnHr1 = 0x80b4 | VehiclePropertyGroup.VENDOR | VehiclePropertyType.INT32 | VehicleArea.GLOBAL;
    private static final int TiAndDateIndcnMins1 = 0x80b5 | VehiclePropertyGroup.VENDOR | VehiclePropertyType.INT32 | VehicleArea.GLOBAL;
    private static final int TiAndDateIndcnMth1 = 0x80b6 | VehiclePropertyGroup.VENDOR | VehiclePropertyType.INT32 | VehicleArea.GLOBAL;
    private static final int TiAndDateIndcnSec1 = 0x80b7 | VehiclePropertyGroup.VENDOR | VehiclePropertyType.INT32 | VehicleArea.GLOBAL;
    private static final int TiAndDateIndcnYr1 = 0x80b8 | VehiclePropertyGroup.VENDOR | VehiclePropertyType.INT32 | VehicleArea.GLOBAL;

    private static final int TIME_INTERVAL_MILLISECOND = 5000;
    private static final int DST_TIME_INTERVAL_MILLISECOND = 60000;
    private static final int TIME_AND_DATE_DATA_VALID = 1;
    private static final int TIME_AND_DATE_DATA_INVALID = 0;
    private static final int YEAR_MAX = 37;
    private static final int YEAR_MIN = 0;
    private static final int MONTH_MAX = 12;
    private static final int MONTH_MIN = 1;
    private static final int DAY_MAX = 31;
    private static final int DAY_MIN = 1;
    private static final int HOUR_MAX = 23;
    private static final int HOUR_MIN = 0;
    private static final int MINS_MAX = 59;
    private static final int MINS_MIN = 0;
    private static final int SEC_MAX = 59;
    private static final int SEC_MIN = 0;
    private static final String TIMEZONE_PROPERTY = "persist.sys.timezone";
    private static final String DEFAULT_TIMEZONE = "Asia/Shanghai";
    private static final String NEWYORK_TIMEZONE = "America/New_York";
    private static final String FIRST_BOOT_COMPLETED = "sys.bootstat.first_boot_completed";

    private int mTiAndDateIndcnDataValid = 0;
    private int mTiAndDateIndcnYr1 = 0; // 年的取值范围为 0 - 37
    private int mTiAndDateIndcnMth1 = 0; // 月的取值范围为 1 - 12
    private int mTiAndDateIndcnDay = 0; // 日的取值范围为 1 - 31
    private int mTiAndDateIndcnHr1 = 0; // 时的取值范围为 0 - 23
    private int mTiAndDateIndcnMins1 = 0; // 分的取值范围为 0 - 59
    private int mTiAndDateIndcnSec1 = 0; // 秒的取值范围为 0 - 59

    @BeforeClass
    public static void testInit() {
        SystemProperties.set(TIMEZONE_PROPERTY, DEFAULT_TIMEZONE);
    }

    @Test
    // 测试系统时间初始化和校准, Android首次启动且同步CEM时间失败
    // 首次开机,如果CEM上报的时间信号无效或者CEM上报的时间信号不在正确取值范围内,ECarXTimeAndDateService会选择2000年1月1日0时0分0秒来初始化Android系统时间
    // 模拟CEM时间上报信号如下：
    // TiAndDateIndcnDataValid=NoYes1_Yes
    // TiAndDateIndcnYr1=100
    // TiAndDateIndcnMth1=13
    // TiAndDateIndcnDay=32
    // TiAndDateIndcnHr1=24
    // TiAndDateIndcnMins1=60
    // TiAndDateIndcnSec1=60
    public void test_TimeAndDate_001() {
        Assert.assertEquals(SystemProperties.getInt(FIRST_BOOT_COMPLETED, 0), 1);
        simulateCEMTimeReport(1, 2100, 13, 32, 24, 60, 60);
        delay(TIME_INTERVAL_MILLISECOND);

        // 使用Calendar获取当前的系统时间(ECarXTimeAndDateService已时间初始化)
        Calendar current = Calendar.getInstance(TimeZone.getTimeZone(SystemProperties.get(TIMEZONE_PROPERTY, DEFAULT_TIMEZONE)));
        Assert.assertEquals(current.get(Calendar.YEAR), 2000);
        Assert.assertEquals(current.get(Calendar.MONTH) + 1, 1);
        Assert.assertEquals(current.get(Calendar.DAY_OF_MONTH), 1);
        Assert.assertEquals(current.get(Calendar.HOUR_OF_DAY), 0);
        Assert.assertEquals(current.get(Calendar.MINUTE), 0);
    }

    @Test
    // 测试系统时间初始化和校准, Android首次启动且同步CEM时间成功
    // 首次开机,如果CEM上报的时间信号有效且CEM上报的时间信号在正确取值范围内,ECarXTimeAndDateService会同步CEM时间至Android侧
    // 模拟CEM时间上报信号如下：
    // TiAndDateIndcnDataValid=NoYes1_Yes
    // TiAndDateIndcnYr1=23
    // TiAndDateIndcnMth1=6
    // TiAndDateIndcnDay=1
    // TiAndDateIndcnHr1=13
    // TiAndDateIndcnMins1=44
    // TiAndDateIndcnSec1=1
    // 即2023年6月1日13时44分1秒
    public void test_TimeAndDate_002() {
        Assert.assertEquals(SystemProperties.getInt(FIRST_BOOT_COMPLETED, 0), 1);
        simulateCEMTimeReport(1, 2023, 6, 1, 13, 44, 1);
        delay(TIME_INTERVAL_MILLISECOND);

        // 使用Calendar获取当前的系统时间(ECarXTimeAndDateService已时间初始化)
        Calendar current = Calendar.getInstance(TimeZone.getTimeZone(SystemProperties.get(TIMEZONE_PROPERTY, DEFAULT_TIMEZONE)));
        Assert.assertEquals(current.get(Calendar.YEAR), 2023);
        Assert.assertEquals(current.get(Calendar.MONTH) + 1, 6);
        Assert.assertEquals(current.get(Calendar.DAY_OF_MONTH), 1);
        Assert.assertEquals(current.get(Calendar.HOUR_OF_DAY), 13);
        Assert.assertEquals(current.get(Calendar.MINUTE), 44);
    }

    @Test
    // 测试系统时间初始化和校准, Android非首次启动且同步CEM时间失败
    // 非首次开机,如果CEM上报的时间信号无效或者CEM上报的时间信号不在正确取值范围内,Android系统时间即为默认时间,ECarXTimeAndDateService不做改变
    // 模拟CEM时间上报信号如下：
    // TiAndDateIndcnDataValid=NoYes1_Yes
    // TiAndDateIndcnYr1=100
    // TiAndDateIndcnMth1=13
    // TiAndDateIndcnDay=32
    // TiAndDateIndcnHr1=24
    // TiAndDateIndcnMins1=60
    // TiAndDateIndcnSec1=60
    public void test_TimeAndDate_003() {
        Assert.assertEquals(SystemProperties.getInt(FIRST_BOOT_COMPLETED, 0), 1);
        simulateCEMTimeReport(1, 2100, 13, 32, 24, 60, 60);
        delay(TIME_INTERVAL_MILLISECOND);

        // 使用Calendar获取当前的系统时间(ECarXTimeAndDateService已时间初始化)
        Calendar current = Calendar.getInstance(TimeZone.getTimeZone(SystemProperties.get(TIMEZONE_PROPERTY, DEFAULT_TIMEZONE)));
        Assert.assertNotEquals(current.get(Calendar.YEAR), 2100);
        Assert.assertNotEquals(current.get(Calendar.MONTH) + 1, 13);
        Assert.assertNotEquals(current.get(Calendar.DAY_OF_MONTH), 32);
        Assert.assertNotEquals(current.get(Calendar.HOUR_OF_DAY), 24);
        Assert.assertNotEquals(current.get(Calendar.MINUTE), 60);
        Assert.assertNotEquals(current.get(Calendar.SECOND), 60);
    }

    @Test
    // 测试系统时间初始化和校准, Android非首次启动且同步CEM时间成功
    // 非首次开机,如果CEM上报的时间信号有效且CEM上报的时间信号在正确取值范围内,ECarXTimeAndDateService会同步CEM时间至Android侧
    // 模拟CEM时间上报信号如下：
    // TiAndDateIndcnDataValid=NoYes1_Yes
    // TiAndDateIndcnYr1=23
    // TiAndDateIndcnMth1=7
    // TiAndDateIndcnDay=2
    // TiAndDateIndcnHr1=23
    // TiAndDateIndcnMins1=55
    // TiAndDateIndcnSec1=1
    // 即2023年7月2日23时55分1秒
    public void test_TimeAndDate_004() {
        Assert.assertEquals(SystemProperties.getInt(FIRST_BOOT_COMPLETED, 0), 1);
        simulateCEMTimeReport(1, 2023, 7, 2, 23, 55, 1);
        delay(TIME_INTERVAL_MILLISECOND);

        // 使用Calendar获取当前的系统时间(ECarXTimeAndDateService已时间初始化)
        Calendar current = Calendar.getInstance(TimeZone.getTimeZone(SystemProperties.get(TIMEZONE_PROPERTY, DEFAULT_TIMEZONE)));
        Assert.assertEquals(current.get(Calendar.YEAR), 2023);
        Assert.assertEquals(current.get(Calendar.MONTH) + 1, 7);
        Assert.assertEquals(current.get(Calendar.DAY_OF_MONTH), 2);
        Assert.assertEquals(current.get(Calendar.HOUR_OF_DAY), 23);
        Assert.assertEquals(current.get(Calendar.MINUTE), 55);
    }

    @Test
    // 测试时间日期设置, CEM主动上报时间至Android且同步CEM时间失败
    // 如果满足1.CEM上报的时间信号有效2.CEM上报的时间信号在正确取值范围内3.CEM上报的时间年月日时分与当前Android一致,ECarXTimeAndDateService会同步CEM时间至Android侧
    public void test_TimeAndDate_005() {
        Calendar before = Calendar.getInstance(TimeZone.getTimeZone(SystemProperties.get(TIMEZONE_PROPERTY, DEFAULT_TIMEZONE)));
        int beforeYear = before.get(Calendar.YEAR);
        int beforeMonth = before.get(Calendar.MONTH);
        int beforeDay = before.get(Calendar.DAY_OF_MONTH);
        int beforeHour = before.get(Calendar.HOUR_OF_DAY);
        int beforeMinute = before.get(Calendar.MINUTE);
        int beforeSecond = before.get(Calendar.SECOND);
        Log.d(TAG, "test_TimeAndDate_005, before time:= "
            + beforeYear + "-" + beforeMonth + "-" + beforeDay + " "
            + beforeHour + ":" + beforeMinute + ":" + beforeSecond);

        simulateCEMTimeReport(1, beforeYear + 1, beforeMonth + 2, beforeDay + 1, beforeHour + 1, beforeMinute + 1, beforeSecond + 1);
        delay(TIME_INTERVAL_MILLISECOND);

        Calendar after = Calendar.getInstance(TimeZone.getTimeZone(SystemProperties.get(TIMEZONE_PROPERTY, DEFAULT_TIMEZONE)));
        int afterYear = after.get(Calendar.YEAR);
        int afterMonth = after.get(Calendar.MONTH);
        int afterDay = after.get(Calendar.DAY_OF_MONTH);
        int afterHour = after.get(Calendar.HOUR_OF_DAY);
        int afterMinute = after.get(Calendar.MINUTE);
        int afterSecond = before.get(Calendar.SECOND);
        Log.d(TAG, "test_TimeAndDate_005, after time:= "
            + afterYear + "-" + afterMonth + "-" + afterDay + " "
            + afterHour + ":" + afterMinute + ":" + afterSecond);

        Assert.assertEquals(beforeYear, afterYear);
        Assert.assertEquals(beforeMonth, afterMonth);
        Assert.assertEquals(beforeDay, afterDay);
        Assert.assertEquals(beforeHour, afterHour);
        Assert.assertEquals(beforeMinute, afterMinute);
    }

    @Test
    // 测试时间日期设置, CEM主动上报时间至Android且同步CEM时间成功
    // 如果满足1.CEM上报的时间信号有效2.CEM上报的时间信号在正确取值范围内3.CEM上报的时间年月日时分与当前Android一致,ECarXTimeAndDateService会同步CEM时间至Android侧
    public void test_TimeAndDate_006() {
        Calendar before = Calendar.getInstance(TimeZone.getTimeZone(SystemProperties.get(TIMEZONE_PROPERTY, DEFAULT_TIMEZONE)));
        int beforeYear = before.get(Calendar.YEAR);
        int beforeMonth = before.get(Calendar.MONTH);
        int beforeDay = before.get(Calendar.DAY_OF_MONTH);
        int beforeHour = before.get(Calendar.HOUR_OF_DAY);
        int beforeMinute = before.get(Calendar.MINUTE);
        int beforeSecond = before.get(Calendar.SECOND);
        Log.d(TAG, "test_TimeAndDate_005, before time:= "
            + beforeYear + "-" + beforeMonth + "-" + beforeDay + " "
            + beforeHour + ":" + beforeMinute + ":" + beforeSecond);

        simulateCEMTimeReport(1, beforeYear, beforeMonth + 1, beforeDay, beforeHour, beforeMinute, beforeSecond + 10);
        delay(TIME_INTERVAL_MILLISECOND);

        Calendar after = Calendar.getInstance(TimeZone.getTimeZone(SystemProperties.get(TIMEZONE_PROPERTY, DEFAULT_TIMEZONE)));
        int afterYear = after.get(Calendar.YEAR);
        int afterMonth = after.get(Calendar.MONTH);
        int afterDay = after.get(Calendar.DAY_OF_MONTH);
        int afterHour = after.get(Calendar.HOUR_OF_DAY);
        int afterMinute = after.get(Calendar.MINUTE);
        int afterSecond = after.get(Calendar.SECOND);
        Log.d(TAG, "test_TimeAndDate_005, after time:= "
            + afterYear + "-" + afterMonth + "-" + afterDay + " "
            + afterHour + ":" + afterMinute + ":" + afterSecond);

        Assert.assertEquals(beforeYear, afterYear);
        Assert.assertEquals(beforeMonth, afterMonth);
        Assert.assertEquals(beforeDay, afterDay);
        Assert.assertEquals(beforeHour, afterHour);
        Assert.assertEquals(beforeMinute, afterMinute);
        Assert.assertTrue(Math.abs(beforeSecond - afterSecond) > 10);
    }

    @Test
    // 测试时间日期设置, Android时间变化响应并下发时间至CEM
    // Android系统时间发生变更时ECarXTimeAndDateService会监听广播并及时将新的时间下发至CEM
    // 模拟下发时间2023年6月1日13时44分1秒
    public void test_TimeAndDate_007() {
        simulateSetSystemTime(2023, 6, 1, 13, 44, 1);
        delay(TIME_INTERVAL_MILLISECOND);

        Calendar current = Calendar.getInstance(TimeZone.getTimeZone(SystemProperties.get(TIMEZONE_PROPERTY, DEFAULT_TIMEZONE)));
        Assert.assertEquals(current.get(Calendar.YEAR), 2023);
        Assert.assertEquals((current.get(Calendar.MONTH) + 1), 6);
        Assert.assertEquals(current.get(Calendar.DAY_OF_MONTH), 1);
        Assert.assertEquals(current.get(Calendar.HOUR), 13);
        Assert.assertEquals(current.get(Calendar.MINUTE), 44);
    }

    @Test
    // 测试时间日期设置, Android时区变化响应并下发时间至CEM
    // Android系统时区发生变更时ECarXTimeAndDateService会监听广播并及时将新的时间下发至CEM
    // 模拟下发时间2023年6月1日13时44分1秒
    // 模拟改变时区至美国纽约时区
    public void test_TimeAndDate_009() {
        simulateSetSystemTime(2023, 6, 1, 13, 44, 1);
        SystemProperties.set(TIMEZONE_PROPERTY, NEWYORK_TIMEZONE);
        delay(TIME_INTERVAL_MILLISECOND);

        Calendar current = Calendar.getInstance(TimeZone.getTimeZone(SystemProperties.get(TIMEZONE_PROPERTY, DEFAULT_TIMEZONE)));
        Assert.assertEquals(current.get(Calendar.YEAR), 2023);
        Assert.assertEquals((current.get(Calendar.MONTH) + 1), 6);
        Assert.assertEquals(current.get(Calendar.DAY_OF_MONTH), 1);
        Assert.assertEquals(current.get(Calendar.HOUR), 1);
        Assert.assertEquals(current.get(Calendar.MINUTE), 44);
    }

    @Test
    // 测试时间日期设置, Android进入夏令时时间变化响应并下发时间至CEM
    // 模拟改变时区至美国纽约时区
    // 模拟设置时间为2023年3月12日1时59分30秒
    // 当30秒后时间变为2023年3月12日2时0分0秒时,由于进入夏令时系统时间会往前拨一小时变成2023年3月12日3时0分0秒
    public void test_TimeAndDate_010() {
        SystemProperties.set(TIMEZONE_PROPERTY, NEWYORK_TIMEZONE);
        simulateSetSystemTime(2023, 3, 12, 1, 59, 30);
        delay(DST_TIME_INTERVAL_MILLISECOND);

        Calendar current = Calendar.getInstance(TimeZone.getTimeZone(SystemProperties.get(TIMEZONE_PROPERTY, DEFAULT_TIMEZONE)));
        Assert.assertEquals(current.get(Calendar.YEAR), 2023);
        Assert.assertEquals((current.get(Calendar.MONTH) + 1), 3);
        Assert.assertEquals(current.get(Calendar.DAY_OF_MONTH), 12);
        Assert.assertEquals(current.get(Calendar.HOUR), 3);
        Assert.assertEquals(current.get(Calendar.MINUTE), 0);
    }

    @Test
    // 测试时间日期设置, Android退出夏令时时间变化响应并下发时间至CEM
    // 模拟改变时区至美国纽约时区
    // 模拟设置时间为2023年11月5日1时59分30秒
    // 当30秒后时间变为2023年11月5日2时0分0秒时,由于进入夏令时系统时间会往后拨一小时变成2023年11月5日1时0分0秒
    public void test_TimeAndDate_011() {
        SystemProperties.set(TIMEZONE_PROPERTY, NEWYORK_TIMEZONE);
        simulateSetSystemTime(2023, 11, 5, 1, 59, 30);
        delay(DST_TIME_INTERVAL_MILLISECOND);

        Calendar current = Calendar.getInstance(TimeZone.getTimeZone(SystemProperties.get(TIMEZONE_PROPERTY, DEFAULT_TIMEZONE)));
        Assert.assertEquals(current.get(Calendar.YEAR), 2023);
        Assert.assertEquals((current.get(Calendar.MONTH) + 1), 11);
        Assert.assertEquals(current.get(Calendar.DAY_OF_MONTH), 5);
        Assert.assertEquals(current.get(Calendar.HOUR), 1);
        Assert.assertEquals(current.get(Calendar.MINUTE), 0);
    }

    private void simulateCEMTimeReport(int valid, int year, int month, int day, int hour, int minute, int second) {
        try {
            mCarPropertyMgr.setIntProperty(TiAndDateIndcnDataValid, VehicleAreaType.VEHICLE_AREA_TYPE_GLOBAL, valid);
            mCarPropertyMgr.setIntProperty(TiAndDateIndcnYr1, VehicleAreaType.VEHICLE_AREA_TYPE_GLOBAL, year - 2000);
            mCarPropertyMgr.setIntProperty(TiAndDateIndcnMth1, VehicleAreaType.VEHICLE_AREA_TYPE_GLOBAL, month);
            mCarPropertyMgr.setIntProperty(TiAndDateIndcnDay, VehicleAreaType.VEHICLE_AREA_TYPE_GLOBAL, day);
            mCarPropertyMgr.setIntProperty(TiAndDateIndcnHr1, VehicleAreaType.VEHICLE_AREA_TYPE_GLOBAL, hour);
            mCarPropertyMgr.setIntProperty(TiAndDateIndcnMins1, VehicleAreaType.VEHICLE_AREA_TYPE_GLOBAL, minute);
            mCarPropertyMgr.setIntProperty(TiAndDateIndcnSec1, VehicleAreaType.VEHICLE_AREA_TYPE_GLOBAL, second);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private void simulateSetSystemTime(int year, int month, int day, int hour, int minute, int second) {
        try {
            Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone(SystemProperties.get(TIMEZONE_PROPERTY, DEFAULT_TIMEZONE)));
            calendar.set(Calendar.YEAR, year);
            calendar.set(Calendar.MONTH, month - 1);
            calendar.set(Calendar.DAY_OF_MONTH, day);
            calendar.set(Calendar.HOUR, hour);
            calendar.set(Calendar.MINUTE, minute);
            calendar.set(Calendar.SECOND, second);
            SystemClock.setCurrentTimeMillis(calendar.getTimeInMillis());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private boolean isCEMTimeValid() {
        try {
            mTiAndDateIndcnDataValid = (int) mCarPropertyMgr.getProperty(TiAndDateIndcnDataValid, VehicleAreaType.VEHICLE_AREA_TYPE_GLOBAL).getValue();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return mTiAndDateIndcnDataValid == TIME_AND_DATE_DATA_VALID;
    }

    private boolean isCEMTimeInRange() {
        getCEMTime();
        if (mTiAndDateIndcnYr1 == 0 && mTiAndDateIndcnMth1 == 1 && mTiAndDateIndcnDay == 1
            && mTiAndDateIndcnHr1 == 0 && mTiAndDateIndcnMins1 == 0 && mTiAndDateIndcnSec1 == 0) {
            return false;
        } else if (mTiAndDateIndcnYr1 > YEAR_MAX || mTiAndDateIndcnYr1 < YEAR_MIN) {
            return false;
        } else if (mTiAndDateIndcnMth1 > MONTH_MAX || mTiAndDateIndcnMth1 < MONTH_MIN) {
            return false;
        } else if (mTiAndDateIndcnDay > DAY_MAX || mTiAndDateIndcnDay < DAY_MIN) {
            return false;
        } else if (mTiAndDateIndcnHr1 > HOUR_MAX || mTiAndDateIndcnHr1 < HOUR_MIN) {
            return false;
        } else if (mTiAndDateIndcnMins1 > MINS_MAX || mTiAndDateIndcnMins1 < MINS_MIN) {
            return false;
        } else if (mTiAndDateIndcnSec1 > SEC_MAX || mTiAndDateIndcnSec1 < SEC_MIN) {
            return false;
        } else {
            return true;
        }
    }

    private void getCEMTime() {
        try {
            mTiAndDateIndcnYr1 = (int) mCarPropertyMgr.getProperty(TiAndDateIndcnYr1, VehicleAreaType.VEHICLE_AREA_TYPE_GLOBAL).getValue();
            mTiAndDateIndcnMth1 = (int) mCarPropertyMgr.getProperty(TiAndDateIndcnMth1, VehicleAreaType.VEHICLE_AREA_TYPE_GLOBAL).getValue();
            mTiAndDateIndcnDay = (int) mCarPropertyMgr.getProperty(TiAndDateIndcnDay, VehicleAreaType.VEHICLE_AREA_TYPE_GLOBAL).getValue();
            mTiAndDateIndcnHr1 = (int) mCarPropertyMgr.getProperty(TiAndDateIndcnHr1, VehicleAreaType.VEHICLE_AREA_TYPE_GLOBAL).getValue();
            mTiAndDateIndcnMins1 = (int) mCarPropertyMgr.getProperty(TiAndDateIndcnMins1, VehicleAreaType.VEHICLE_AREA_TYPE_GLOBAL).getValue();
            mTiAndDateIndcnSec1 = (int) mCarPropertyMgr.getProperty(TiAndDateIndcnSec1, VehicleAreaType.VEHICLE_AREA_TYPE_GLOBAL).getValue();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}